package com.ruoyi.secondvitim.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.secondvitim.domain.VitimIndex;
import com.ruoyi.secondvitim.service.IVitimIndexService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 第二受害者首页简介Controller
 * 
 * @author alonso_ecit
 * @date 2025-09-22
 */
@RestController
@RequestMapping("/secondVitim/vitimIndex")
public class VitimIndexController extends BaseController
{
    @Autowired
    private IVitimIndexService vitimIndexService;

    /**
     * 查询第二受害者首页简介列表
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:vitimIndex:list')")
    @GetMapping("/list")
    public TableDataInfo list(VitimIndex vitimIndex)
    {
        startPage();
        List<VitimIndex> list = vitimIndexService.selectVitimIndexList(vitimIndex);
        return getDataTable(list);
    }

    /**
     * 导出第二受害者首页简介列表
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:vitimIndex:export')")
    @Log(title = "第二受害者首页简介", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VitimIndex vitimIndex)
    {
        List<VitimIndex> list = vitimIndexService.selectVitimIndexList(vitimIndex);
        ExcelUtil<VitimIndex> util = new ExcelUtil<VitimIndex>(VitimIndex.class);
        util.exportExcel(response, list, "第二受害者首页简介数据");
    }

    /**
     * 获取第二受害者首页简介详细信息
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:vitimIndex:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(vitimIndexService.selectVitimIndexById(id));
    }

    /**
     * 新增第二受害者首页简介
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:vitimIndex:add')")
    @Log(title = "第二受害者首页简介", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VitimIndex vitimIndex)
    {
        return toAjax(vitimIndexService.insertVitimIndex(vitimIndex));
    }

    /**
     * 修改第二受害者首页简介
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:vitimIndex:edit')")
    @Log(title = "第二受害者首页简介", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VitimIndex vitimIndex)
    {
        return toAjax(vitimIndexService.updateVitimIndex(vitimIndex));
    }

    /**
     * 删除第二受害者首页简介
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:vitimIndex:remove')")
    @Log(title = "第二受害者首页简介", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(vitimIndexService.deleteVitimIndexByIds(ids));
    }
}
